import React, {Component} from 'react';
import BasicTab from '../ErpBase/BasicTab';
import SysMenuList from './components/SysMenuList';
import SysDictList from './components/SysDictList';
import SysAreaList from './components/SysAreaList';
import './ErpSystem.scss';
import API from '../../tools/API';
import CommonUtils from '../../tools/CommonUtils';
/**
*  系统设置
*/
export default class ErpSystem extends Component{
  constructor(props) {
     super(props);
     this.state = {
       tab:'menu',
       tabs:[],
     }
  }

  //初始化
  componentWillMount(){
    //原始数据
    const tabs = [
      { tab: '菜单管理', key: 'menu'},
      { tab: '字典管理', key: 'dict'},
      { tab: '地区管理', key: 'area'},
    ];
    //设置数据
    this.setState({
      tab:this.props.match.params != undefined?this.props.match.params.path:'menu',
      tabs:CommonUtils.getUserTabs(tabs)
    })
  }

  render(){
    return(
      <div className="base-setting-main">
        <BasicTab tabs={this.state.tabs} activeKey={this.state.tab} changeTab={(val)=> this.setState({tab:val})}/>
        {
          this.state.tab == 'dict'?
            <SysDictList />
          :
          this.state.tab == 'area'?
            <SysAreaList />
          :
            <SysMenuList />
        }
      </div>
    )
  }

}
